package com.company.crm.workbench.service.impl;

import com.company.crm.workbench.domain.Activity;
import com.company.crm.workbench.mapper.ActivityMapper;
import com.company.crm.workbench.service.ActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者：王磊栋
 * 2021/4/17
 */
@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private ActivityMapper activityMapper;
    @Override
    public List<Activity> selectActivityByPageAndOther(Map<String, Object> map) {
        return activityMapper.selectAllActivityByPageAndOther(map);
    }

    @Override
    public List<Activity> selectAllActivity() {
        return activityMapper.selectAllActivity();
    }

    @Override
    public List<Activity> selectActivityByIds(String[] ids) {
        return activityMapper.selectActivityByIds(ids);
    }

    @Override
    public int insertByList(List<Activity> lists) {
        return activityMapper.insertByList(lists);
    }

    @Override
    public long selectAllActivitiesCountsByConditions(Map<String, Object> map) {
        return activityMapper.selectAllActivitiesCountsByConditions(map);
    }

    @Override
    public int createActivity(Activity activity) {
        return activityMapper.insertActivity(activity);
    }

    //单个删除，或者批量删除
    @Override
    public int deleteActivityByIDs(String[] ids) {
        return activityMapper.deleteActivityByIds(ids);
    }

    @Override
    public int updateActivity(Activity activity) {
        return activityMapper.updateActivity(activity);
    }

    @Override
    public Activity queryActivityById(String id) {
        return activityMapper.selectActivityById(id);
    }

    /*@Override
    public PageInfo<Activity> selectByPage(int pageNo,int PageSize) {
        //调用查询所以有的activity
        Map<String,Object> map = new HashMap<>();
        PageHelper.startPage(pageNo, PageSize);
        List<Activity> activities = activityMapper.selectAllActivityByPageAndOther(map);
        PageInfo<Activity> infolist = new PageInfo<>(activities);
        return infolist;
    }*/

    @Override
    public List<Activity> selectActivityByClueID(String name, String id) {
        return activityMapper.selectActivityByClueID(name, id);
    }
}
